<meta charset="utf-8">
<div id="export_word">
    <div class="row exam-title">
    	<p id="examTitle" th:text="${grade.examination.title}"></p>
    </div>
    <div class="row exam-info">
    	<div class="col-xs-6 col-sm-5 text-right">
    		<p th:text="'（考试科目：'+${grade.examination.subject.name}"></p>
    	</div>
    	<div class="col-xs-6 col-sm-3 text-center">
    		<p th:text="'考试时间：'+${grade.examination.examTime}+'分钟'"></p>
    	</div>
    	<div class="col-xs-6 col-sm-4">
    		<p th:text="'试卷总分：'+${grade.examination.totalScore}+'分）'"></p>
    	</div>
    </div>
    <div class="row user-info">
        <p>
        	<label class="col-xs-6 col-sm-3"> 学院: 
        		<input th:value="${grade.user.institute.instituteName}" disabled/>
        	</label>
            <label class="col-xs-6 col-sm-3"> 班级: 
            	<input th:value="${grade.user.classes.className}" disabled/>
            </label>
            <label class="col-xs-6 col-sm-3"> 学号: 
            	<input th:value="${grade.user.username}" disabled/>
            </label>
            <label class="col-xs-6 col-sm-3"> 姓名: 
            	<input id="username" th:value="${grade.user.nickname}" disabled/>
            </label>
        </p>
    </div>
    <div class="row score-info">
    	<table class="table table-bordered text-center">
    		<tbody>
    			<tr>
    				<td style="border: 2px solid black">题型</td>
    				<td style="border: 2px solid black">选择题</td>
    				<td style="border: 2px solid black">问答题</td>
    				<td style="border: 2px solid black">总分</td>
    				<td style="border: 2px solid black">出卷人</td>
    				<td style="border: 2px solid black">评分人</td>
    			</tr>
    			<tr>
    				<td style="border: 2px solid black">得分</td>
    				<td style="border: 2px solid black" th:text="${grade.autoResult}"></td>
    				<td style="border: 2px solid black" th:text="${grade.manulResult}"></td>
    				<td style="border: 2px solid black" th:text="${grade.result}"></td>
    				<td style="border: 2px solid black" th:text="${grade.examination.author}"></td>
    				<td style="border: 2px solid black" th:text="${grade.examination.author}"></td>
    			</tr>
    		</tbody>
		</table>
    </div>
    <div class="ShortAnswer">
        <p id="ShortAnswerTitle"><span class="line_height">&nbsp;&nbsp;&nbsp;&nbsp;三、 简答题</span></p>
        <ol>
        	<li th:each="question,questionInfo:${grade.examination.questions}" th:if="${question.questionType==2}">
		        <p class="question_title mt10" th:text="${question.title}+'（'+${question.score}+'分）'"></p>
		        <div class="article-body markdown-body editor-preview-active-side" style="margin-top:10px;border-width:0px" th:utext="${question.content}"></div>
		        <textarea class="form-control mb10" rows="6" th:text="${question.stuAnswer}" readonly></textarea>
		        <p class="text-success" th:text="${question.answer}==''?'参考答案：无':'参考答案：'+${question.answer}"></p>
		        <p class="text-danger" th:text="${question.parse}==''?'答案解析：无解析':'答案解析：'+${question.parse}"></p>
        		<div class="input-group">
        			<form th:id="'markForm'+${questionInfo.index}">
	        			<div class="row">
	                		<div class="col-xs-8" style="padding-right:0px">
		                		<input type="text" th:id="${questionInfo.index}" class="form-control" placeholder="请给出分数"  number="data-number" require="">
		                	</div>
			                <div class="input-group-btn" th:id="'a'+${questionInfo.index}">
			                	<button type="button" th:onclick="'markScore('+${questionInfo.index}+')'" class="btn btn-danger">打分</button>
			                </div>
			            </div>
		            </form>
                </div>
        	</li>
        </ol>
        <form id="markDetailForm">
        	<input name="id" type="hidden" th:value="${grade.id}">
		    <input name="manulResult" id="manulResult" type="hidden" th:value="${grade.manulResult}">
        </form>
    </div>
    <div class="box-footer">
        <div class="pull-right">
            <button type="button" id="saveDetailMark" class="btn btn-info">确定</button>
            <button type="button" data-dismiss="modal" class="btn btn-default">取消</button>
        </div>
    </div>
</div>
<script>
    $(function () {
        $("#saveDetailMark").on('click', function () {
            if (doValidForm("#markDetailForm")) {
                Core.mask("#saveDetailMark");
                Core.postAjax("/grade/mark",$("#markDetailForm").serialize(),function (data) {
                    if (data.status == 200) {
                        Core.unmask("#saveDetailMark");
                        $("#markingModal").modal("hide");
                        Core.refreshTable("#table",true);
                    }
                    layer.msg(data.msg);
                })
            }
        });
    });
    
    function markScore(id){
    	var manulResult = parseInt($("#manulResult").val());
    	if (doValidForm("#markForm"+id)) {
	    	var score = parseInt($("#"+id).val());
	    	$("#"+id).attr("readonly","readonly");
	    	$("#a"+id).hide();
	    	manulResult+=score;
	    	$("#manulResult").val(manulResult);
    	}
    }
</script>